package diva.pap.widget;

import diva.android_library.rpc.Response;
import diva.lib.net.UrlBuilder;
import diva.pap.model.RequestBase;

public class WidgetDataRequest extends RequestBase<WidgetDataRequest> {

  public static final String ACTION = "widget";

  public WidgetDataRequest(Response<WidgetDataRequest> response) {
    super(null, ACTION, response);
  }

  public String getClicksCount() {
    return data.getNumber("clicks").intValue() + "";
  }

  public String getTransactionsCount() {
    return data.getNumber("transactions").intValue() + "";
  }

  @Override
  public UrlBuilder getUrl() {
    return createLoginUrl(application.getSettings().getServerUrl(), getAction(), application
        .getSettings().getUsername(), application.getSettings().getPassword());
  }

  @Override
  public void send() {
    process();
  }

  @Override
  protected void doLater(Runnable runnable) {
    runnable.run();
  }
}
